<?php
/**
 * Created by PhpStorm.
 * User: 跳梁
 * Date: 2015/11/16
 * Time: 14:12
 */
class communityModule extends Module{

    function __construct() {
        $this->includePhp('community', 'community');
    }

    public function call($user,$method,$param){
        switch($method){
            case 'index':
                $qid = $param->qid;
                if (!isset($qid)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::getIndex($qid);
                break;
            case 'contentList':
                $qid = $param->qid;
                $start = $param->start;
                $limit = $param->limit;
                if (!isset($qid)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::contentList($qid,$start,$limit);
                break;
            case 'setTop':
                $qid = $param->qid;
                $sid = $param->sid;
                if (!isset($qid)||!isset($sid)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::setTop($sid,$qid);
                break;
            case 'cancelTop':
                $qid = $param->qid;
                $sid = $param->sid;
                if (!isset($qid)||!isset($sid)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::cancelTop($sid,$qid);
                break;
            case 'deleted':
                $id = $param->id;
                if (!isset($id)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::deleted($id);
                break;
            case 'getComment':
                $sid = $param->sid;
                $qid = $param->qid;
                if (!isset($sid)||!isset($qid)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::getComment($sid,$qid);
                break;
            case 'saveComment':
                $sId = $param->sId;
                $qid = $param->qid;
                $uId = $param->uId;
                $replyId = $param->replyId;
                $comment = $param->comment;
                if (!isset($sId)||!isset($qid)||!isset($uId)||!isset($comment)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::saveComment($sId,$uId,$qid,$comment,$replyId);
                break;
            case 'post':
                $picUrl = $param->picUrl;
                $content = $param->content;
                $qid = $param->qid;
                $uid = $param->uid;
                if (!isset($content)||!isset($qid)||!isset($uid)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::post($picUrl,$content,$qid,$uid);
                break;
            case 'addPraise':
                $sId = $param->sId;
                $qid = $param->qid;
                $uId = $param->uId;
                if (!isset($sId)||!isset($qid)||!isset($uId)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::addPraise($sId,$qid,$uId);
                break;
            case 'deletedPraise':
                $uId = $param->uId;
                $sId = $param->sId;
                $qid = $param->qid;
                if (!isset($uId)||!isset($sId)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::deletedPraise($uId,$sId,$qid);
                break;
            case 'deletedComment':
                $id = $param->id;
                $sId = $param->sId;
                if (!isset($id)||!isset($sId)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::deletedComment($id,$sId);
                break;
            case 'userPromotion':
                $qid = $param->qid;
                if(!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::userPromotion($qid);
                break;
            case 'recruitUserList':
                $qid = $param->qid;
                $cid = $param->cid;
                $type = $param->type;
                $start = $param->start;
                $limit = $param->limit;
                if(!isset($qid)||!isset($cid)||!isset($type)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::recruitUserList($cid,$qid,$type,$start,$limit);
                break;
            case 'getPromotionCode':
                $qid = $param->qid;
                $uid = $param->uid;
                $module = $param->module;
                $moduleId = $param->moduleId;
                if(!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::getPromotionCode($qid,$uid,$module,$moduleId);
                break;
            case 'promotionCode':
                community::promotionCode($param);
                break;
            case 'newFansMessage':
                $qid = $param->qid;
                $uid = $param->uid;
                $userName = $param->userName;
                $cid = $param->cid;
                community::newFansMessage($qid,$uid,$userName,$cid);
                break;
            case 'getFansCount':
                $qid = $param->qid;
                community::getFansCount($qid);
                break;
            case 'distributionProduct':
                $qid = $param->qid;
                if(!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::distributionProduct($qid);
                break;
            case 'getProductByCondition':
                $qid = $param->qid;
                $vid = $param->vid;
                $tagId = $param->tagId;
                $sort = $param->sort;
                $start = $param->start;
                $name = $param->name;
                $limit = $param->limit;
                if(!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::getProductByCondition($vid,$tagId,$qid,$sort,$start,$limit,$name);
                break;
            case "personConfig":
                $qid = $param->qid;
                $phone = $param->phone;
                $qrcode = $param->qrcode;
                $themeImg = $param->themeImg;
                $name = $param->name;
                if(!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::personConfig($qid,$phone,$qrcode,$themeImg,$name);
                break;
            case "getContactInfo":
                $qid = $param->qId;
                $uid = $param->miUId;
                $currentUid = $param->currentUid;
                return community::getContactInfo($qid,$uid,$currentUid);
                break;
            case 'getProductCode':
                $pid = $param->pid;
                $qid = $param->qid;
                if(!isset($qid)||!isset($pid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::getProductCode($pid,$qid);
                break;
            case 'refereeInfo':
                $qid = $param->qid;
                $start = $param->start;
                $limit = $param->limit;
                if(!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::refereeInfo($qid,$start,$limit);
                break;
            case 'quanTeam':
                $teamId = $param->teamId;
                if(!isset($teamId)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::quanTeam($teamId);
                break;
            case "teamUser":
                $id = $param->teamId;
                $uid = $param->uid;
                $start = $param->start;
                $limit=$param->limit;
                if(!isset($id)||!isset($uid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::teamUser($id,$uid,$start,$limit);
                break;
            case "fansList":
                $mallId = $param->mallId;
                $qid = $param->qid;
                $uid = $param->uid;
                $start = $param->start;
                $limit = $param->limit;
                $page = $param->page;
                if(!isset($mallId)||!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::fansList($mallId,$uid,$qid,$start,$limit,$page);
                break;
            case "miQrcode":
                $qid = $param->qid;
                $mallId = $param->mallId;
                $uid = $param->uid;
                if(!isset($qid)||!isset($mallId)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::miQrcode($qid,$mallId,$uid);
                break;
            case "deletedTeamUser":
                $id = $param->id;
                if(!isset($id)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::deletedTeamUser($id);
                break;
            case "inviteJoinTeam":
                $id = $param->id;
                $time = $param->share;
                if(!isset($id)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::inviteJoinTeam($id,$time);
                break;
            case "joinTeam":
                $id = $param->id;
                if(!isset($id)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::joinTeam($id);
                break;
            //获取个人详细信息
            case "getUserInfo":
                community::getUserInfo($param);
                break;
            //删除用户
            case "deleteQuanUser":
                community::deleteQuanUser($param);
                break;
            //获得销售源列表
            case "saleSourceFansList":
                $qid = $param->qid;
                $start = $param->start;
                $limit = $param->limit;
                $search = $param->search;
                $register = $param->register;
                $order = $param->order;
                if(!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::saleSourceFansList($qid,$start,$limit,$search,$register,$order);
                break;
            //好友列表
             case "friendsList":
                $qid = $param->qid;
                $uid = $param->uid;
                $search = $param->search;
                $register = $param->register;
                $order = $param->order;
                $start = $param->start;
                $limit = $param->limit;
                $excel = $param->excel;
                $startTime = $param->startTime;
                $endTime = $param->endTime;
                $all = $param->all;
                $uids = $param->uids;
                if(!isset($uid)||!isset($qid)){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                community::friendsList($uid,$qid,$search,$register,$order,$start,$limit,$excel,$startTime,$endTime,$all,$uids);
                break;
            //获得签名信息
            case "getSignPackage":
                community::getSignPackage($param);
		break;
            case "userActionList":
                community::userActionList($param);
                break;
            case 'saveClickContact':
                if(!$param->miUid && !$param->moduleId){
                    return false;
                }
                return community::saveClickContact($param);
                break;
            case 'setFriendNameAlias':
                $friendId = $param->friendId;
                $alias = $param->alias;
                community::setFriendNameAlias($friendId, $alias);
                break;
            case 'getPoster':
                $module = $param->module;
                $moduleId = $param->moduleId;
                community::getPoster($module, $moduleId);
                break;
            default:
                break;
        }

    }
}

$module = new communityModule();
Module::addModule($module);
